// TOWN SCRIPT
//    Town 10: Hengest

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;

short i,j,k,r1,choice;

body;

beginstate INIT_STATE;
	set_name(6,"Scyld");
	set_name(21,"Freawaru");
	set_name(22,"Weland");
	set_name(23,"Heorot");			
	set_name(24,"Wulfgar");	
	set_name(25,"Raemmen");		
	set_state_continue(16);
break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;
// This state is called every turn the party is in this town.
break;

beginstate 10;
	block_entry(1);
	reset_dialog_preset_options(5);
	choice = run_dialog(0);
	if (choice == 2) {
		move_to_new_town(18,41,23);
		end();
		}
break;

beginstate 11;
	if (get_flag(100,0) >= 12)
		set_state_continue(12);
break;

beginstate 12;
	if (get_flag(100,0) == 12)
		set_state_continue(14);
	set_state_continue(13);
break;

beginstate 13;
	print_str("The guards let you pass.");
break;

beginstate 14;
	if (get_flag(10,0) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"As you approach the entrance to the throne room, a messenger bolts through you and crashes into the room. You attempt to get inside to see what's happening, but the guards cross their spears and momentarily bar your entrance.",0);
	add_dialog_str(1,"_You shall be met with shortly,_ one of them says. _Lay down your arms here._",0);
	add_dialog_str(2,"You hesistate. Through the door, still, you hear hurried speech. Something important must have happened. As you're just about to drop your weapons, though, the door opens.",0);
	add_dialog_str(3,"_Let them come in. This is not a time for tradition or paranoia. Come._",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(10,0,250);
break;

beginstate 15;
	set_town_visibility(19,1);
break;

beginstate 16;
	if (get_flag(100,0) >= 12)
		set_state_continue(17);
	set_state_continue(27);
break;

beginstate 17;
	flip_terrain(31,25);
	flip_terrain(32,25);
	flip_terrain(33,25);
	set_state_continue(27);
break;

beginstate 20;
	if (has_special_item(46) > 0)
		end();
	set_state_continue(21);
break;

beginstate 21;
	reset_dialog();
	add_dialog_str(0,"She rises with a probing look on her face, looking you up and down until it begins to make you uncomfortable.",0);
	add_dialog_str(1,"_This is an marvellous opportunity. If Sorali wants a representative from Hengest, I shall oblige. He will be surprised on more than one term. Meet me on the docks of Fresan._",0);
	add_dialog_str(2,"She calls for a guard and quickly writes a message. Handing it over to the messenger, she whispers some words in his ear. He dashes off.",0);
	add_dialog_str(3,"_Well? Are you departing or not?_",0);
	add_dialog_choice(0,"Yes.");
	add_dialog_choice(1,"No.");
	choice = run_dialog(1);
	if (choice == 1)
		set_state_continue(23);
	if (choice == 2)
		set_state_continue(22);
break;

beginstate 22;
	message_dialog("_Not quite ready? Prepare then. Call me when you are._","");
break;

beginstate 23;
	message_dialog("She takes a contract from her desk and hands it to you.",
	  "_Take this. At the docks of Fresan, I shall contact you._");
	change_spec_item(46,1);
break;

beginstate 24;
	reset_dialog();
	add_dialog_str(0,"On the pedestal is laid a large book, opened to a specific chapter. The writing is at best vague and overblown, as well as being highly inventive with spelling and grammar. Very typical of a treatise on arcane matters.",0);
	add_dialog_str(1,"- MIRREURS -",0);
	add_dialog_str(2,"Thou shalt come to reconnise in this world, should it be that thou travellest oft and rest few, that the places of ours are Connect, and so that is to saie, with the nececerie intruments and para-metres, that the Others of the Metaverse be nigh.",0);
	add_dialog_str(3,"Ouest lieth one thereof such, and on that Isle do thrive the beastly creations of Nether and Shadow. Ouest lieth the gate that onward shalt lead, and drives he and they who is or are worthy to the Realm of the Mist.",0);
	add_dialog_str(4,"Yet not all who seek shall find. The fate-weavers alone know, and judge.",0);
	add_dialog_str(5,"[It goes on. The rest of it is much less understandable than this segment. You decide to leave it alone.]",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
break;

beginstate 25;
	if (get_flag(81,0) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"Perched upon a high plateau, Castle Hengest is crafted entirely of a pale white stone, slightly browned by the years. Raised high up, with a single banner of the Falcon fluttering above it, the castle dwarfs the scattered buildings around it.",0);
	add_dialog_str(1,"Ominous sentries stand watch on the ramparts. The frigid north wind passes through, raising a long shiver. Contrasted with the snow-crowned peaks behind it, Hengest seems indeed a castle in the clouds.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(81,0,250);
break;

beginstate 26;
	if (get_flag(81,0) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"You emerge in the entrance to a large guard-hall. Several of them stare at you quietly as you pass. The walls are crafted of a fine white rock, though the reflecting red firelight gives it a strange coloring.",0);
	add_dialog_str(1,"This is your first welcome to Castle Hengest. Not much in the way of friendliness, but still - you have been summoned by the King. It would be best to find him quickly.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(81,0,250);
break;

beginstate 27;
	if (get_flag(100,0) >= 12)
		set_state_continue(26);
	set_state_continue(25);
break;

